package cs575.wido.action;

import cs575.client.Session;
import cs575.client.WiDo;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import cs575.wido.UserSession;
import cs575.wido.WebServiceFactory;
import cs575.wido.ui.TaskDetailsWindow;
import cs575.wido.ui.TaskWindow;
import javax.swing.JOptionPane;

public class ViewTaskAction extends AbstractAction {
	private cs575.client.Task task;
	private TaskWindow parent;
	
	public ViewTaskAction(TaskWindow parent) {
		putValue(NAME, "Task Details");
		this.parent = parent;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		this.task = parent.getSelectedTask();
		if (task != null) {
			TaskDetailsWindow tdw = new TaskDetailsWindow(task);
			tdw.setAction(new EditTaskAction(tdw, parent));
			tdw.setVisible(true);
		}
		else {
			JOptionPane.showMessageDialog(null, "task is null");
		}
	}
}
